package com.macro.mall.controller;

import com.macro.mall.common.annotation.AccessLimit;
import com.macro.mall.common.annotation.NoLog;
import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.dto.SmsOperateLogQuery;
import com.macro.mall.model.SmsOperateLog;
import com.macro.mall.service.SmsOperateLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 字典管理Controller
 *
 * @author 郎
 */
@Controller
@Api(tags = "SmsOperateLogController")
@Tag(name = "SmsOperateLogController", description = "操作日志查询")
@RequestMapping("/operateLog")
@AllArgsConstructor
public class SmsOperateLogController {

    private final SmsOperateLogService smsOperateLogService;

    @AccessLimit
    @NoLog
    @ApiOperation("分页查询操作日志")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<CommonPage<SmsOperateLog>> list(SmsOperateLogQuery query, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        List<SmsOperateLog> list = smsOperateLogService.list(query, pageNum, pageSize);
        return CommonResult.success(CommonPage.restPage(list));
    }

    @AccessLimit
    @ApiOperation("根据ID获取操作日志详情")
    @RequestMapping(value = "/detail/{id}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<Object> detail(@PathVariable("id") Long id) {
        return CommonResult.success(smsOperateLogService.detail(id));
    }
}
